package com.example.iot.common;

import android.app.Activity;
import android.support.annotation.Nullable;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.iot.R;

public class TopBarBussiness implements TopBarListener {

    private Activity activity;
    private ImageView ivBack, icOne, icTwo;
    private TextView tvTitle, rightText;

    public TopBarBussiness(Activity activity) {
        this.activity = activity;
        ivBack = activity.findViewById(R.id.iv_back);
        tvTitle = activity.findViewById(R.id.tv_title);
        icOne = activity.findViewById(R.id.ic_one);
        icTwo = activity.findViewById(R.id.ic_two);
        rightText = activity.findViewById(R.id.tv_one);
    }

    @Override
    public void backImage(@Nullable int resId) {
        ivBack.setImageResource(resId);
        activity.finish();
    }

    @Override
    public void titleText(String title) {
        tvTitle.setText(title);
    }

    @Override
    public void iconOne(boolean isIcon, int resId) {
        if (isIcon) {
            icOne.setImageResource(resId);
        }
    }

    @Override
    public void iconTwo(boolean isIcon, int resId) {
        if (isIcon)
            icTwo.setImageResource(resId);
    }

    @Override
    public void rightText(String text) {
        rightText.setText(text);
    }

    private void routerToActivity() {

    }
}
